#include <iostream>
#include "bundle.h"
#include <string>
#include <fstream>   


using namespace std;

int main(int argc, char* argv[]){
    if(argc < 3){
        cout << "argv[1] : 输入需要压缩的文件名(路径)" << endl;
        cout << "argv[2] : 输入压缩后的文件名(路径)" << endl;
        return 1;
        
    }
    ifstream ifs;
    string ifilename = argv[1];
    string ofilename = argv[2];
    ifs.open(ifilename,std::ios::binary);

    ifs.seekg(0,std::ios::end);
    auto sz = ifs.tellg();
    ifs.seekg(0,std::ios::beg);

    string s1;
    s1.resize(sz);
    
    ifs.read(&s1[0],sz);
    string zip = bundle::pack(bundle::LZIP, s1);
    ifs.close();

    ofstream ofs;
    ofs.open(ofilename,std::ios::binary);
    ofs.write(&zip[0], zip.size());
    ofs.close();

    return 0;
}
